package com.stellar.circle.controller.admin.sSchool;

import com.stellar.circle.controller.admin.sSchool.vo.SSchoolRequestPageVO;
import com.stellar.circle.controller.admin.sSchool.vo.SSchoolRequestVO;
import com.stellar.circle.controller.admin.sSchool.vo.SSchoolResponseVO;
import com.stellar.circle.domain.sSchool.SSchoolDomainService;

import com.stellar.web.core.bean.PageResult;
import com.stellar.web.core.bean.Result;
import com.stellar.web.core.constants.AuthUserConstants;
import com.stellar.web.core.validator.ValidatorRole;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 学校信息表控制器
 *
 * @author Jqchan
 * @version 1.0
 * @date 2025-05-17 18:48:37
 */
@RequestMapping("/api-admin/sSchool")
@RestController("adminSSchoolController")
@Slf4j
public class SSchoolController {

    @Resource
    private SSchoolDomainService sSchoolDomainService;

    /**
     * 分页查询学校信息表
     */
    @ValidatorRole
    @PostMapping("/page")
    public Result<PageResult<SSchoolResponseVO>> page(@RequestBody SSchoolRequestPageVO requestPageVO) {
        return Result.success(sSchoolDomainService.page(requestPageVO));
    }

    /**
     * 新增学校信息表
     */
    @ValidatorRole
    @PostMapping("/create")
    public Result<Boolean> create(@RequestBody SSchoolRequestVO requestVO) {
        return Result.success(sSchoolDomainService.insert(requestVO));
    }

    /**
     * 修改学校信息表
     */
    @ValidatorRole
    @PostMapping("/update")
    public Result<Boolean> update(@RequestBody SSchoolRequestVO requestVO) {
        return Result.success(sSchoolDomainService.update(requestVO));
    }

    /**
     * 删除学校信息表
     */
    @ValidatorRole
    @DeleteMapping("/delete/{id}")
    public Result<Boolean> delete(@PathVariable("id") Long id) {
        return Result.success(sSchoolDomainService.delete(id));
    }

    /**
     * 获取学校信息表详情
     */
    @ValidatorRole
    @GetMapping("/get/{id}")
    public Result<SSchoolResponseVO> get(@PathVariable("id") Long id) {
        return Result.success(sSchoolDomainService.get(id));
    }

    /**
     * 获取当前用户下的学校列表
     */
    @ValidatorRole(value = {AuthUserConstants.SUPER_ADMIN, AuthUserConstants.SCHOOL_ADMIN})
    @GetMapping("/getSchoolListByUser")
    public Result<List<SSchoolResponseVO>> getSchoolListByUser() {
        return Result.success(sSchoolDomainService.getSchoolListByUser());
    }

}
